<?php
#注册插件
RegisterPlugin("baobk","ActivePlugin_baobk");

function ActivePlugin_baobk() {
Add_Filter_Plugin('Filter_Plugin_Admin_TopMenu','baobk_AddMenu');
	Add_Filter_Plugin('Filter_Plugin_ViewList_Template','baobk_tags_set');
	Add_Filter_Plugin('Filter_Plugin_ViewPost_Template','baobk_tags_set');
}
function baobk_AddMenu(&$m){
	global $zbp;
	array_unshift($m, MakeTopMenu("root",'主题设置',$zbp->host . "zb_users/theme/baobk/main.php","","topmenu_baobk"));
}
function baobk_tags_set(&$template){
	global $zbp;
	//基本设置
    $template->SetTags('baobk_description',$zbp->Config('baobk')->description); //网站首页描述
	$template->SetTags('baobk_keyword',$zbp->Config('baobk')->keyword); //网站关键词
	$template->SetTags('baobk_guanggao',$zbp->Config('baobk')->guanggao);
}
function InstallPlugin_baobk() {
global $zbp;
if(!$zbp->Config('baobk')->HasKey('Version')){
		$zbp->Config('baobk')->Version = '1.0';
         //基本设置
		$zbp->Config('baobk')->description = '描述';//网站首页描述 
		$zbp->Config('baobk')->keyword = '关键字'; //网站首页关键词
		$zbp->Config('baobk')->gg = '网站公告'; //网站首页公告
		$zbp->Config('baobk')->seo = '1';
		$zbp->Config('baobk')->about = '底部关于';
		$zbp->Config('baobk')->lx = '底部联系';
		$zbp->SaveConfig('baobk');
	}
	$zbp->Config('baobk')->Version = '1.0';
	$zbp->SaveConfig('baobk');
}
//侧栏评论
function baobk_side_comm() {
    global $zbp;
	
	$i = $zbp->modulesbyfilename['comments']->MaxLi;
	if ($i == 0) $i = 5;
	$comments = $zbp->GetCommentList('*', array(array('=', 'comm_IsChecking', 0)), array('comm_PostTime' => 'DESC'), $i, null);

	$s = '';
	foreach ($comments as $comment) {
		$s .= '
		<li class="zan-list clearfix">
                <div class="sidebar-avatar">
                  <img src="'.$comment->Author->Avatar.'" width="75" height="75" alt="'.$comment->Author->Name.'" class="lazy avatar avatar-75 wp-user-avatar wp-user-avatar-75 alignnone photo" style="display: inline;"></div>
                 <h6>
                  发表于：<a href="' . $comment->Post->Url .'">' . $comment->Post->Title .'</a>
                 </h6>
                <div class="sidebar-comment">
                  <a href="' . $comment->Post->Url .'#cmt' . $comment->ID .'">
                    ' . TransferHTML($comment->Content, '[noenter]') . '              </a>
                </div>
              </li>';
	}

	return $s;
}
function baobk_side_Tags(){
	global $zbp,$str;
	$str = '';
	$i = $zbp->modulesbyfilename['tags']->MaxLi;
	if ($i == 0) $i = 24;
	$array = $zbp->GetTagList('','',array('tag_Count'=>'DESC'),array($i),'');

	foreach ($array as $tag) {
		$str .= '<a href="' . $tag->Url . '">' . $tag->Name . '<span class="tag-count"> (' . $tag->Count . ')</span></a>';
	}

	return $str;
}
function UninstallPlugin_baobk() {
global $zbp;

}

?>